package com.project.restaurant.order.dao;

import com.project.restaurant.order.dto.MealItem;
import org.apache.ibatis.annotations.*;

@Mapper
public interface MealItemDao {


    @Results(id = "MealItemResultMap",value = {
            @Result(column = "meal_id",property = "mealId"),
            @Result(property = "mealType",
                    one = @One(resultMap = "com.project.restaurant.mapper.MealTypeMapper.MealTypeResultMap")),
            @Result(property = "mealPictures",
                    many = @Many(resultMap = "com.project.restaurant.mapper.MealPictureMapper.MealPictureResultMap"))

    })
    @Select("select m.meal_id,m.meal_name,m.meal_type_id,mt.meal_type,mp.meal_picture_url " +
            "from meal m " +
            "join r_meal_type mt on m.meal_type_id = mt.meal_type_id " +
            "join r_meal_picture mp on m.meal_id = mp.meal_id where m.meal_id = #{mealId}")
    MealItem selectById(int mealId);
}
